var btns = document.getElementsByTagName("button"),
    imgs = document.getElementsByClassName("a1"),
    lis = document.getElementsByClassName("a2"),
    j = 0;
  
for (var i in btns) {
    btns[i].onclick = function () {
        if (this.innerText == ">") {
            j++;
            j == 4 && (j = 0);
            for (var i = 0; i < lis.length; i++) {
                lis[i].className = "a2";
                imgs[i].className = "a1";
            }
            imgs[j].className = "active a1";
            lis[j].className = "active a2";
        } else {
            j--;
            j == -1 && (j = 3);
            for (var i = 0; i < lis.length; i++) {
                lis[i].className = "a2";
                imgs[i].className = "a1";
            }
            imgs[j].className = "active a1";
            lis[j].className = "active a2";
        }
    }
}

for (var i in lis) {
    lis[i].onclick = function () {
        j = this.getAttribute("dy");
        for (var i = 0; i < lis.length; i++) {
            lis[i].className = "a2";
            imgs[i].className = "a1";
        }
        imgs[j].className = "active a1";
        lis[j].className = "active a2";
    }
}
timer=setInterval(function(){
    j++;
    j == 4 && (j = 0);
    for (var i = 0; i < lis.length; i++) {
        lis[i].className = "a2";
        imgs[i].className = "a1";
    }
    imgs[j].className = "active a1";
    lis[j].className = "active a2";
},2000);


car.onmouseover=function(){
    clearInterval(timer);
}

car.onmouseout=function(){
timer=setInterval(function(){
    j++;
    j == 4 && (j = 0);
for (var i = 0; i < lis.length; i++) {
    lis[i].className = "a2";
    imgs[i].className = "a1";
}
    imgs[j].className = "active a1";
    lis[j].className = "active a2";
    },2000);
}